package com.wetool.wechat.entity;

import lombok.Getter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 *
 */
@Getter
@Entity()
@Table()
public class WechatAccountRelation {
    /**
     * 微信全局唯一unionId
     */
    @Id
    private String unionId;
    /**
     * 微兔用户id
     */
    @Column(unique = true)
    private Long userId;
    /**
     * 微信用户在微兔公众号OpenId
     */
    @Column()
    private String officialOpenId;
    /**
     * 微信用户在微兔小程序OpenId
     */
    @Column()
    private String minaOpenid;

    /**
     * 微信用户在微兔开放平台的OpenId
     */
    @Column()
    private String openPlatformOpenId;

    /**
     * 微信二维码代码
     */
    @Column()
    private String ticket;


    public WechatAccountRelation() {

    }

    public WechatAccountRelation(String unionId, String openPlatformOpenId) {
        this.unionId = unionId;
        this.openPlatformOpenId = openPlatformOpenId;
    }

    public void bindUserId(long userId) {
        this.userId = userId;
    }


    public void bindOfficialOpenId(String openId) {
        this.officialOpenId = openId;
    }

    public void unbindOfficialOpenId() {
        this.officialOpenId = null;
    }

    public void bindTicket(String ticket) {
        this.ticket = ticket;
    }

    public void clearTicket() {
        this.ticket = null;
    }
}
